IF exists(SELECT * FROM dbo.sysobjects WHERE name='fr_geefRapport' AND xtype='P') 
BEGIN
	DROP PROCEDURE fr_geefRapport
END
GO

CREATE      procedure fr_geefRapport(@formaat varchar(20),
@iNr char(7),@aard char(1),@periode char(2),@jaar char(4))
as
set nocount on
select XMLtekst,XSLtekst 
from  fr_XML as xml 
	left join fr_XSL as xsl
	on xml.groepsnaam = xsl.groepsnaam
		and xml.periode = xsl.periode
		  and xml.aard = xsl.aard
		    and xml.jaar = xsl.jaar
where xml.inschrijvingsNr = @iNr 
	and xml.periode=@periode 
	  and xml.aard=@aard
	    and xml.jaar = @jaar
	      and xsl.formaat = @formaat